package com.skhu.as.dao;

import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;

import com.skhu.as.domain.ProcessStatus;
import com.skhu.as.mapper.ProcessStatusM;

public class ProcessStatusD {

	private JdbcTemplate jdbcTemplate;

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
	
	public List<ProcessStatus> getProcessStatusList(){
		String sql = "SELECT process_status_no, process_status FROM process_status";
		List<ProcessStatus> processStatusList = jdbcTemplate.query(sql, new ProcessStatusM());
		return processStatusList;
	}
	
	public int deleteAllProcessStatus(){
		String sql = "DELETE FROM process_status";
		int result = jdbcTemplate.update(sql);
		return result;
	}
	
	public int getProcessStatusMaxNo(){
		String sql = "SELECT MAX(process_status_no) FROM process_status";
		int result = jdbcTemplate.queryForInt(sql);
		return result;
	}
	
	public int insertProcessStatus(int processStatusMaxNo, String processStatus){
		String sql = "INSERT INTO process_status VALUES (?,?)";
		Object[] param = new Object[]{
				processStatusMaxNo,
				processStatus
		};
		int result = jdbcTemplate.update(sql, param);
		return result;
	}
	
}
